<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>

<script>
    $(function () {
        $("#Audiolist").treegrid({
            url:"${pageContext.request.contextPath}/getAllAlbum",
            idField:'id',
            treeField:'name',
            columns:[[
                {field:'name',title:'OLDNAME',width:100,align:'right'},
                /*{field:'audioUrl',align:"IMAGE",title:'图片',width:100,align:'right',
                    formatter: function(value,row,index){

                        return "<image  height='30px' src='${pageContext.request.contextPath}"+value+"'>";
                    }},*/
                {field:'albumId',title:'STATE',width:100,align:'right'},
                {field:'audioSize',title:'DATE',width:100,align:'right'},
                {field:'audioOrder',title:'DESCRIPTION',width:100,align:'right'},
            ]],
            onDblClickRow:function(row){
                $('#addAudioDialog').dialog("open");

                if(row.albumId){
                    $("#albumId").val(row.albumId);
                }else{
                    $("#albumId").val(row.id);
                }

            }
        });


        $('#addAudioDialog').dialog({
            title: '添加文章',
            width: 400,
            height: 200,
            closed: true,
            buttons:"#addaudiobtn",

        });
    })

    function doaddaudio(){
        $('#addAudioform').form('submit', {
            url:"${pageContext.request.contextPath}/addAudio",
            onSubmit: function(){
                // do some check
                // return false to prevent submit;
                return true;
            },
            success:function(data){
                var jsobj=JSON.parse(data);
                $.messager.alert('我的消息',jsobj.message,'info');
                $("#Audiolist").datagrid("load");
                $('#addAudioDialog').dialog("close");
            }
        });
    }

</script>


<table id="Audiolist"></table>

<div id="addAudioDialog">
    <form id="addAudioform" method="post" enctype="multipart/form-data">
        章节名：<input name="audioName"><br>
        章节音频文件:<input type="file" name="audioFile"><br>
        <input type="text" name="albumId" id="albumId">
        章节大小：<input name="audioSize"><br>
        章节循序：<input name="audioOrder"><br>
    </form>

</div>
<div id="addaudiobtn">
    <a href="javascript:doaddaudio()" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">确认</a>
</div>